package com.robot.controller;


import com.github.pagehelper.PageInfo;

import com.robot.common.result.Response;
import com.robot.dao.dto.CompanyDTO;

import com.robot.dao.dto.CompanyPageDTO;
import com.robot.dao.dto.UserDTO;
import com.robot.dao.vo.CompanyVO;
import com.robot.dao.vo.UserInfoVO;
import com.robot.service.CompanyService;
import com.robot.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/company")
@Slf4j
@Api(tags = "企业相关接口")
public class CompanyController {

    @Autowired
    private UserService userService;

    @Autowired
    private CompanyService companyService;



    @PostMapping("/generateInvitationCode")
    @ApiOperation("生成企业邀请码")
    public Response<String> generateInvitationCode(@RequestBody CompanyDTO companyDTO) {
       String invitationCode= companyService.generateInvitationCode(companyDTO);
        return Response.success(invitationCode);
    }


    @PostMapping("/pageCompanyUserList")
    @ApiOperation("查询企业用户信息")
    public Response<PageInfo<UserInfoVO>> pageCompanyUserList(@RequestBody CompanyPageDTO companyDTO) {
        //TODO:分页待处理封装
        PageInfo<UserInfoVO> pageResult = companyService.pageCompanyUserList(companyDTO);
        return Response.success(pageResult);
    }


    @PostMapping("/setCompanyManager")
    @ApiOperation("用户设置企业管理员")
    public Response setCompanyManager(@RequestBody UserDTO userDTO) {
        userService.setCompanyManager(userDTO);
        return Response.success();
    }


    @PostMapping("/removeCompany")
    @ApiOperation("移除企业")
    public Response removeCompany(@RequestBody UserDTO userDTO) {
        userService.removeCompany(userDTO);
        return Response.success();
    }


}
